﻿using System.Linq;
using XRM.Security.DataAccess.Context;
using XRM.Security.DataAccess.Enums;
using XRM.Security.DataAccess.Models;

namespace XRM.Security.DataAccess.Repositories.Impl
{
    public class UserRegisterRepository : BaseRepository<UserRegister>
    {
        public UserRegisterRepository(IDbContext dbContext) : base(dbContext)
        {}

        public IQueryable<UserRegister> GetWorkedUsers()
        {
            return GetAll( s => s.Status == (int)UserStatus.Work );
        }

        public IQueryable<UserRegister> GetUsersByFio(string fio)
        {
            var workedUsers = GetWorkedUsers();
            return workedUsers.Where( s => (s.LastName + " " + s.FirstName + " " + s.MotherName).StartsWith(fio) );
        }
    }
}
